package com.study.designmodes.controller.pattern.strategy.threelevel;

import com.study.designmodes.enums.BusinessCodeEnum;
import com.study.designmodes.request.BusinessObjectRequest;
import com.study.designmodes.service.executor.businessTask.BusinessTaskExecutorRegister;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 策略第三种方式控制器
 *
 * @author yangyanbin
 * @date 2023/02/01
 * @since 20230201
 */
@RestController
public class StrategyThreeController {


    /**
     * 策略三个方法
     */
    @RequestMapping("/strategyThree/{code}")
    public void strategyThreeMethod(@PathVariable("code") String code) throws Exception {
        BusinessCodeEnum codeEnum = BusinessCodeEnum.getByCode(code);
        if (ObjectUtils.isEmpty(codeEnum)) {
            throw new Exception("业务枚举不存在！");
        }
        BusinessObjectRequest objectRequest = new BusinessObjectRequest();
        objectRequest.setAreaCode("11001");
        objectRequest.setCode("ERKIIOIP");
        objectRequest.setBusinessCode(codeEnum);
        BusinessTaskExecutorRegister.findByType(codeEnum).doExecute(objectRequest);
    }
}
